package com.jiyun.service.impl;

import com.jiyun.entity.Compony;
import com.jiyun.dao.ComponyDao;
import com.jiyun.service.ComponyService;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * (Compony)表服务实现类
 *
 * @author makejava
 * @since 2020-11-12 14:03:45
 */
@Service("componyService")
public class ComponyServiceImpl implements ComponyService {
    @Autowired
    private ComponyDao componyDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public Compony queryById(Integer id) {
        return this.componyDao.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<Compony> queryAllByLimit(int offset, int limit) {
        return this.componyDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param compony 实例对象
     * @return 实例对象
     */
    @Override
    public Compony insert(Compony compony) {
        this.componyDao.insert(compony);
        return compony;
    }

    /**
     * 修改数据
     *
     * @param compony 实例对象
     * @return 实例对象
     */
    @Override
    public Compony update(Compony compony) {
        this.componyDao.update(compony);
        return this.queryById(compony.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.componyDao.deleteById(id) > 0;
    }

    @Override
    public List<Compony> find(Integer cid) {
        return componyDao.find(cid);
    }
}